Runtime Issues with "richTextWithOle" function

Dear all,

i am currently running a script that will find me all requirements with strike through markup and ask me if I want to set a deletion marker (status attribute) for it.

This works nicely actually. Now comes the but: But if an object contains a big OLE object the runtime of the script goes up by hours. Sometimes it takes like 30mins to one hour till the script can pass that specific object.

I would use "richText" but that function cannot find strike though markup it seems.

So my question is: Is there some way to discern real OLE objects from strike-through markup so I don't have to process objects that hold big ole objects? Perhaps you also know of another way on how to handle this?

Appreciate any help :-)

Best Regards,
Alexander
SystemAdmin - Wed Apr 20 08:37:34 EDT 2011

Re: Runtime Issues with "richTextWithOle" function
adevicq - Wed Apr 20 09:19:14 EDT 2011

Hi,

Have you tried with "richTextNoOle" ?
Alain

Re: Runtime Issues with "richTextWithOle" function
SystemAdmin - Wed Apr 20 09:41:04 EDT 2011

adevicq - Wed Apr 20 09:19:14 EDT 2011
Hi,

Have you tried with "richTextNoOle" ?
Alain

Hi Alain,

thanks for your help.
As I said I need richTextWithOle, as otherwise you cannot check for strike-through markup.

I could solve the problem in the meanwhile by using lower case buffers instead of a string to hold the result of my richTextWithOle calls. Suddenly everything worked fine ;)

Best Regards,
Alex

Re: Runtime Issues with "richTextWithOle" function
Mathias Mamsch - Wed Apr 20 10:22:26 EDT 2011

SystemAdmin - Wed Apr 20 09:41:04 EDT 2011
Hi Alain,

thanks for your help.
As I said I need richTextWithOle, as otherwise you cannot check for strike-through markup.

I could solve the problem in the meanwhile by using lower case buffers instead of a string to hold the result of my richTextWithOle calls. Suddenly everything worked fine ;)

Best Regards,
Alex

By the way this post has some code, which might allow you to skip the OLE object in the richText ... Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: Runtime Issues with "richTextWithOle" function
llandale - Wed Apr 20 16:26:49 EDT 2011

SystemAdmin - Wed Apr 20 09:41:04 EDT 2011
Hi Alain,

thanks for your help.
As I said I need richTextWithOle, as otherwise you cannot check for strike-through markup.

I could solve the problem in the meanwhile by using lower case buffers instead of a string to hold the result of my richTextWithOle calls. Suddenly everything worked fine ;)

Best Regards,
Alex

Yes, richTextNoOle(attr) looks like a winner here; but I think that's the same as richText(attr).

I get the feeling you are parsing the Rich Text directly looking for strike through markup, such as "\\strike " (that is not preceded by an odd number of slashes). Yes, that's likely to get hopelessly complicated and trigger lots of memory loss if you used a string variable. All that stuff should be staged in Buffers for any program dealing with lots of object's text.

Having said that, you would go back to using a string to parse the RichText chunks. May look like this:

RichTextParagraph rtp
RichText rt
string Text = richTextWithOle(obj."Object Text")
bool  HasStrike = false
 
for rtp in Text do
{  for rt in rtp do
   {  if (rt.strikethrough)
      {  HasStrike = true
         break     // don't bother looking further
      }
   }
}
if (HasStrike) then perhaps delete this object.


I wonder if you should instead put the text into a Buffer, then "for rtp in tempStringOf(buf) do".

 

 

  • Louie

 

 

 

  • Louie

 

Re: Runtime Issues with "richTextWithOle" function
SystemAdmin - Thu Apr 21 03:38:07 EDT 2011

llandale - Wed Apr 20 16:26:49 EDT 2011

Yes, richTextNoOle(attr) looks like a winner here; but I think that's the same as richText(attr).

I get the feeling you are parsing the Rich Text directly looking for strike through markup, such as "\\strike " (that is not preceded by an odd number of slashes). Yes, that's likely to get hopelessly complicated and trigger lots of memory loss if you used a string variable. All that stuff should be staged in Buffers for any program dealing with lots of object's text.

Having said that, you would go back to using a string to parse the RichText chunks. May look like this:

RichTextParagraph rtp
RichText rt
string Text = richTextWithOle(obj."Object Text")
bool  HasStrike = false
 
for rtp in Text do
{  for rt in rtp do
   {  if (rt.strikethrough)
      {  HasStrike = true
         break     // don't bother looking further
      }
   }
}
if (HasStrike) then perhaps delete this object.


I wonder if you should instead put the text into a Buffer, then "for rtp in tempStringOf(buf) do".

 

 

  • Louie

 

 

 

  • Louie

 

Dear all,

thanks for your additional advice.

The actual winner code looked like this in the end

RichTextParagraph rp;
    RichText rt;
        bool blnPossiblyRemoved = false;
        bufObjectContent = richTextWithOle(obj."Object Heading") richTextWithOle(obj."Object Text");
        setlower(bufObjectContent);
        
        if(contains(bufObjectContent, "remove",0)!=-1)
        {
                blnPossiblyRemoved = true;
        }
        else if(contains(bufObjectContent, "delete",0)!=-1)
        {
                blnPossiblyRemoved = true;
        }
        else 
        {
                for rp in stringOf(bufObjectContent) do 
                {
                for rt in rp do
                {
                    if(rt.strikethru)
                    {
                            blnPossiblyRemoved = true;
                    }
                }
                }    
        }

 


If you just substitute "bufObjectContent" with a string variable you get loads of performance problems. So Buffers are the real winners here.

An additional hint:
The last loop around the rich text paragraphs will not find any strike-through mark up if you do not use "getRichTextWithOle" although it will find bold, and italic markup. Seems like strike-through markup is saves as an ole, while bold and italic is not. That was actually the root cause of the problem.

Best Regards,
Alex

 

Re: Runtime Issues with "richTextWithOle" function
Mathias Mamsch - Thu Apr 21 06:22:55 EDT 2011

SystemAdmin - Thu Apr 21 03:38:07 EDT 2011

Dear all,

thanks for your additional advice.

The actual winner code looked like this in the end

RichTextParagraph rp;
    RichText rt;
        bool blnPossiblyRemoved = false;
        bufObjectContent = richTextWithOle(obj."Object Heading") richTextWithOle(obj."Object Text");
        setlower(bufObjectContent);
        
        if(contains(bufObjectContent, "remove",0)!=-1)
        {
                blnPossiblyRemoved = true;
        }
        else if(contains(bufObjectContent, "delete",0)!=-1)
        {
                blnPossiblyRemoved = true;
        }
        else 
        {
                for rp in stringOf(bufObjectContent) do 
                {
                for rt in rp do
                {
                    if(rt.strikethru)
                    {
                            blnPossiblyRemoved = true;
                    }
                }
                }    
        }

 


If you just substitute "bufObjectContent" with a string variable you get loads of performance problems. So Buffers are the real winners here.

An additional hint:
The last loop around the rich text paragraphs will not find any strike-through mark up if you do not use "getRichTextWithOle" although it will find bold, and italic markup. Seems like strike-through markup is saves as an ole, while bold and italic is not. That was actually the root cause of the problem.

Best Regards,
Alex

 

I am pretty sure that is not true (strike through being stored as OLE). Makes no sense. Not sure what the root cause was, but normally you can definitly get striked text using richText:
 

Object o = current 
 
string someOLE ="{\\rtf1\\ansi\\ansicpg936\\deff0{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}}
\\viewkind4\\uc1\\pard\\lang1031\\f0\\fs20{\\pict\\wmetafile8\\picw26\\pich26\\picwgoal3000\\pichgoal100
0100090000033a0000000000240000000000050000000b0200000000050000000c021a001a0024
000000430f2000cc00000001000100000000001a001a0000000000280000000100000001000000
010018000000000004000000c40e0000c40e000000000000000000000000ff00030000000000
}\\par
Hello {\\strike guys} {\\ul people}\\par
}
"
 
o."Object Text" = richText someOLE
 
string s2 = richTextWithOle o."Object Text"
print "RichTextWithOle:\n" s2 "\n"
 
string s1 = richText o."Object Text"
print "RichText:\n" s1 "\n\n"

 


This prints:

 

 

 

RichText:
{\rtf1\ansi\ansicpg936\deff0{\fonttbl{\f0\fnil\fcharset0 Tahoma;}}
\viewkind4\uc1\pard\lang1031\f0\fs20\objattph\'20\par
Hello \strike guys\strike0  \ul people\ulnone\par
}



so strike through is retained ... Regards, Mathias



 

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

Re: Runtime Issues with "richTextWithOle" function
SystemAdmin - Thu Apr 21 07:07:18 EDT 2011

Mathias Mamsch - Thu Apr 21 06:22:55 EDT 2011

I am pretty sure that is not true (strike through being stored as OLE). Makes no sense. Not sure what the root cause was, but normally you can definitly get striked text using richText:
 

Object o = current 
 
string someOLE ="{\\rtf1\\ansi\\ansicpg936\\deff0{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}}
\\viewkind4\\uc1\\pard\\lang1031\\f0\\fs20{\\pict\\wmetafile8\\picw26\\pich26\\picwgoal3000\\pichgoal100
0100090000033a0000000000240000000000050000000b0200000000050000000c021a001a0024
000000430f2000cc00000001000100000000001a001a0000000000280000000100000001000000
010018000000000004000000c40e0000c40e000000000000000000000000ff00030000000000
}\\par
Hello {\\strike guys} {\\ul people}\\par
}
"
 
o."Object Text" = richText someOLE
 
string s2 = richTextWithOle o."Object Text"
print "RichTextWithOle:\n" s2 "\n"
 
string s1 = richText o."Object Text"
print "RichText:\n" s1 "\n\n"

 


This prints:

 

 

 

RichText:
{\rtf1\ansi\ansicpg936\deff0{\fonttbl{\f0\fnil\fcharset0 Tahoma;}}
\viewkind4\uc1\pard\lang1031\f0\fs20\objattph\'20\par
Hello \strike guys\strike0  \ul people\ulnone\par
}



so strike through is retained ... Regards, Mathias



 

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

This may be true if you search directly in the RTF string.

But what I am saying is, that if you replace "richTextWithOle" with "richText" or "richTextNoOle" in my code, than it will not find any strike-through RTF parts using RichParagraphs.

Re: Runtime Issues with "richTextWithOle" function
llandale - Thu Apr 21 10:26:05 EDT 2011

SystemAdmin - Thu Apr 21 07:07:18 EDT 2011
This may be true if you search directly in the RTF string.

But what I am saying is, that if you replace "richTextWithOle" with "richText" or "richTextNoOle" in my code, than it will not find any strike-through RTF parts using RichParagraphs.

I'm not having any trouble finding strike through text using just the RT in RTP loop like you have. You don't need setlower() except to find "Remove" and "Delete"; it finds it with an OLE but retrieved with richTextNoOle() and richText(). Something is rotten in Denmark here. Is it possible you are trying to find strikeout text with IN the OLE?

NitPicks: your existing code creates a huge string for placement into the Buffer, put the parts in separately:
bufObjectContent = create()
bufObjectContent += richTextWithOle(obj."Object Heading")
bufObjectContent += richTextWithOle(obj."Object Text")
bla bla bal
delete(bufObjectContent)

Use tempStringOf() when retrieving the string for your loop.

The "contains" command for strings is very suspect; it will not find "xdelete" for example. For this purpose you could perhaps retrieve the raw text and use regexp to search for delete and remove.

  • Louie

Re: Runtime Issues with "richTextWithOle" function
Mathias Mamsch - Thu Apr 21 10:46:26 EDT 2011

SystemAdmin - Thu Apr 21 07:07:18 EDT 2011
This may be true if you search directly in the RTF string.

But what I am saying is, that if you replace "richTextWithOle" with "richText" or "richTextNoOle" in my code, than it will not find any strike-through RTF parts using RichParagraphs.

It might be the right associative devil that haunted you:

The line

bufObjectContent = richTextWithOle(obj."Object Heading") richTextWithOle(obj."Object Text");

 


will be actually parsed as:

 

 

 

bufObjectContent = richTextWithOle( obj."Object Heading" richTextWithOle (obj."Object Text") );



Meaning you will apply richTextWithOle twice, and probably this will remove your striked out text.

Regards, Mathias



 

 

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

 

Re: Runtime Issues with "richTextWithOle" function
Mathias Mamsch - Thu Apr 21 10:58:24 EDT 2011

Mathias Mamsch - Thu Apr 21 10:46:26 EDT 2011

It might be the right associative devil that haunted you:

The line

bufObjectContent = richTextWithOle(obj."Object Heading") richTextWithOle(obj."Object Text");

 


will be actually parsed as:

 

 

 

bufObjectContent = richTextWithOle( obj."Object Heading" richTextWithOle (obj."Object Text") );



Meaning you will apply richTextWithOle twice, and probably this will remove your striked out text.

Regards, Mathias



 

 

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

 

Just to clear things up! richTextWithOle cannot be applied twice, since it will only take an Attr__ as a parameter, so no right associativity problem using richTextWithOle ... 'richText' however will take a string as a parameter and therefore be applied twice. So this code works for me:
 

RichTextParagraph rp;
RichText rt;
 
Object obj = current
Buffer b = create() 
b = (richText obj."Object Heading") (richText obj."Object Text");
setlower b
    
for rp in stringOf(b) do {
    for rt in rp do {
        if(rt.strikethru) {
           print "Found strike!"
        }
    }
}

 


Regards, Mathias

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

Re: Runtime Issues with "richTextWithOle" function
llandale - Thu Apr 21 12:19:49 EDT 2011

Mathias Mamsch - Thu Apr 21 10:58:24 EDT 2011

Just to clear things up! richTextWithOle cannot be applied twice, since it will only take an Attr__ as a parameter, so no right associativity problem using richTextWithOle ... 'richText' however will take a string as a parameter and therefore be applied twice. So this code works for me:
 

RichTextParagraph rp;
RichText rt;
 
Object obj = current
Buffer b = create() 
b = (richText obj."Object Heading") (richText obj."Object Text");
setlower b
    
for rp in stringOf(b) do {
    for rt in rp do {
        if(rt.strikethru) {
           print "Found strike!"
        }
    }
}

 


Regards, Mathias

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

Are you saying that:
... b = richText(o."A") richText(o."B")
is the same as:
... b = richText(o."A" richText(b."B"))
??
And that's because of that odd feature that parens around a single string parameter are ignored?

  • Louie

Re: Runtime Issues with "richTextWithOle" function
Mathias Mamsch - Thu Apr 21 14:43:28 EDT 2011

llandale - Thu Apr 21 12:19:49 EDT 2011
Are you saying that:
... b = richText(o."A") richText(o."B")
is the same as:
... b = richText(o."A" richText(b."B"))
??
And that's because of that odd feature that parens around a single string parameter are ignored?

  • Louie

That is exactly what I am saying. Note that the "." operator has precedence over concatenation. It is the same as calling
 

string s = (o."A") ( richText (o."B") )
// string richText(string) perm is called!
Buffer b = richText s

 


With richTextWithOle you don't have the problem because there is only the richTextWithOle(Attr__) perm. Therefore you cannot do richTextWithOle (string) and therefore the concatenation works.

Regards, Mathias

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS